﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityLibrary;
using System.Data;

namespace Medicare.Tool
{
    public class ReadConfig
    {
        private static List<MedicareTypeEntity> medicareTypeEntity;

        public static List<MedicareTypeEntity> GetConfig()
        {
            if (medicareTypeEntity != null)
            {
                return medicareTypeEntity;
            }
            List<MedicareTypeEntity> t = new List<MedicareTypeEntity>();
            string path = System.Windows.Forms.Application.StartupPath + "MedicareType.xml";

            try
            {
                DataSet ds = new DataSet();
                ds.ReadXml(path);
                foreach (DataRow row in ds.Tables["MedicareType"].Rows)
                {
                    MedicareTypeEntity type = new MedicareTypeEntity();
                    type.MedicareValue = row["CODE"].ToString();
                    type.MedicareText = row["TEXT"].ToString();

                    t.Add(type);
                }
            }
            catch (Exception e)
            {

                throw new Exception("获取配置文件失败！详细信息:" + e.Message);
            }

            medicareTypeEntity = t;

            return t;
        }

    }
}
